//
//  LXVisitorViewController.swift
//  weibo
//
//  Created by 罗心 on 16/6/25.
//  Copyright © 2016年 罗心. All rights reserved.
//

import UIKit

class LXVisitorViewController: UITableViewController {
    
    let isLogin: Bool = LXUserAccountTools.sharedTools.isLogin
    
    var visitorView: LXVisitorView?
    
    override func loadView() {
        if isLogin {
            super.loadView()
        }else{
            setVisitorView()
        }
    }
    
    //设置访客视图
    private func setVisitorView(){
        setupNav()
        visitorView = LXVisitorView()
        
        visitorView?.closure = {[weak self] in
            self?.loginClick()
        }
        
        view = visitorView
        
    }
    
    //MARK: 设置导航栏
    private func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(LXVisitorViewController.loginClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(LXVisitorViewController.loginClick))
    }
    
     //MARK: 监听点击事件
    @objc private func loginClick(){
        // 弹出登录控制器
        let oauthVc = LXOAuthViewController()
        let navC = UINavigationController(rootViewController: oauthVc)
        
        presentViewController(navC, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

}
